package com.bbx.tessercat_demo.eng;


import org.bytedeco.javacpp.*;
import org.bytedeco.javacpp.lept.*;
import org.bytedeco.javacpp.tesseract.*;

import static org.bytedeco.javacpp.lept.*;

public class EngController {

    public static void main(String [] args){
        BytePointer outText;
        TessBaseAPI api = new TessBaseAPI();
 /*       if (api.Init("C:\\Users\\kaifacs\\Downloads", "eng") != 0) {
            System.err.println("Could not initialize tesseract.");
            System.exit(1);
        }*/
 //指定语言库文件--从官网下载
        api.Init("C:\\Users\\kaifacs\\Downloads","testlang+chi_sim+eng");
//        api.Init("C:\\Users\\kaifacs\\Downloads","chi_sim");

        // Open input image with leptonica library
        PIX image = pixRead("C:\\Users\\kaifacs\\Downloads\\sxb.jpg");
        api.SetImage(image);
        // Get OCR result
        outText = api.GetUTF8Text();
        System.out.println("OCR output:\n" + outText.getString());

        // Destroy used object and release memory
        api.End();
        outText.deallocate();
        pixDestroy(image);
    }





}
